package org.jiuling.network.tools.request.http.config;


import org.jiuling.network.tools.request.http.enums.RequestMethodEnum;
import org.jiuling.network.tools.request.http.model.HttpRequestBody;
import org.jiuling.network.tools.request.http.model.HttpRequestHeader;
import org.jiuling.network.tools.request.http.model.HttpRequestParam;

import java.net.Proxy;

/**
 * Http请求数据配置
 * @author 紫灵
 * @date 2024年02月20日 22时27分48秒
 */
public class HttpRequestDataConfig {

    /** 代理 */
    private Proxy proxy;
    /** 请求方式 */
    protected RequestMethodEnum requestMethod = RequestMethodEnum.GET;
    /** 链接超时事件 */
    private Integer connectTimeout = 3000;
    /** 读取超时时间 */
    private Integer readTimeout = 5000;
    /** Http请求参数 */
    private HttpRequestParam httpRequestParam;
    /** 请求头 */
    private HttpRequestHeader httpRequestHeader;
    /** Http请求体 */
    private HttpRequestBody httpRequestBody;

    public Proxy getProxy() {
        return proxy;
    }

    public RequestMethodEnum getRequestMethod() {
        return requestMethod;
    }

    public Integer getConnectTimeout() {
        return connectTimeout;
    }

    public Integer getReadTimeout() {
        return readTimeout;
    }

    public HttpRequestParam getHttpRequestParam() {
        return httpRequestParam;
    }

    public HttpRequestHeader getHttpRequestHeader() {
        return httpRequestHeader;
    }

    public HttpRequestBody getHttpRequestBody() {
        return httpRequestBody;
    }



    public Builder builder(){
        return new Builder(this);
    }

    public static class Builder{
        private final HttpRequestDataConfig httpRequestDataConfig;

        public Builder(HttpRequestDataConfig httpRequestDataConfig) {
            this.httpRequestDataConfig = httpRequestDataConfig;
        }

        public Builder setProxy(Proxy proxy) {
            httpRequestDataConfig.proxy = proxy;
            return this;
        }

        public Builder setRequestMethod(RequestMethodEnum requestMethod) {
            httpRequestDataConfig.requestMethod = requestMethod;
            return this;
        }

        public Builder setConnectTimeout(Integer connectTimeout) {
            httpRequestDataConfig.connectTimeout = connectTimeout;
            return this;
        }

        public Builder setReadTimeout(Integer readTimeout) {
            httpRequestDataConfig.readTimeout = readTimeout;
            return this;
        }

        public Builder setHttpRequestParam(HttpRequestParam httpRequestParam) {
            httpRequestDataConfig.httpRequestParam = httpRequestParam;
            return this;
        }

        public Builder setHttpRequestHeader(HttpRequestHeader httpRequestHeader) {
            httpRequestDataConfig.httpRequestHeader = httpRequestHeader;
            return this;
        }

        public Builder setHttpRequestBody(HttpRequestBody httpRequestBody) {
            httpRequestDataConfig.httpRequestBody = httpRequestBody;
            return this;
        }

        public HttpRequestDataConfig build(){
            return httpRequestDataConfig;
        }
    }
}
